package org.ariadne_eu.hcifetcher.servlet;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.ariadne_eu.hcifetcher.rest.RestUtils;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;

public class RemoveTodoServlet extends HttpServlet {

	@Override
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		String todoid = req.getParameter("todoid");
		DatastoreService datastore = DatastoreServiceFactory
				.getDatastoreService();
		RestUtils ruts = new RestUtils();
		Entity todoitem = ruts.getSingleEntity(todoid);
		datastore.delete(todoitem.getKey());
	}

	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		doPost(req, resp);
	}

}
